home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_01 / show.c < prev    next >
C/C++ Source or Header  |  1993-11-15  |  27KB  |  746 lines

  1. /***********************************************************************/
  2. /* SHOW.C - Functions involving displaying the data.                   */
  3. /***********************************************************************/
  4. /*
  5.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  6.  * Copyright (C) 1991-1993 Mark Hessling
  7.  *
  8.  * This program is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU General Public License as
  10.  * published by the Free Software Foundation; either version 2 of
  11.  * the License, or any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16.  * General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to:
  20.  *
  21.  *    The Free Software Foundation, Inc.
  22.  *    675 Mass Ave,
  23.  *    Cambridge, MA 02139 USA.
  24.  *
  25.  *
  26.  * If you make modifications to this software that you feel increases
  27.  * it usefulness for the rest of the community, please email the
  28.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  29.  * This software is going to be maintained and enhanced as deemed
  30.  * necessary by the community.
  31.  *
  32.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  33.  * 36 David Road                     Phone: +61 7 849 7731
  34.  * Holland Park                      Fax:   +61 7 875 5314
  35.  * QLD 4121
  36.  * Australia
  37.  */
  38.  
  39. /*
  40. $Header: C:\THE\RCS\show.c 1.4 1993/09/01 16:27:15 MH Interim MH $
  41. */
  42.  
  43. #include <stdio.h>
  44. #include <time.h>
  45.  
  46. #include "the.h"
  47. #include "proto.h"
  48.  
  49. /*#define TRACEE*/
  50. /*-------------------------- external data ----------------------------*/
  51. extern LINE *next_line,*curr_line;
  52. extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
  53. extern char current_screen;
  54. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  55. extern char current_file;         /* pointer to current file */
  56. extern char number_of_views;                        /* number of views */
  57. extern char number_of_files;                   /* number of open files */
  58. extern char display_screens;                      /* number of screens */
  59. extern bool horizontal;
  60. extern WINDOW *foot,*error_window;
  61. extern bool error_on_screen;
  62. extern char mode_insert;        /* defines insert mode toggle */
  63. extern char in_profile;    /* indicates if processing profile */
  64. extern char file_disposition;
  65. /*------------------------ function definitions -----------------------*/
  66. #ifdef PROTO
  67. static void show_line(int direction,LINE *curr,
  68.                          short rows,short start_row);
  69. #else
  70. static void show_line();
  71. #endif
  72. /***********************************************************************/
  73. #ifdef PROTO
  74. void show_heading(void)
  75. #else
  76. void show_heading()
  77. #endif
  78. /***********************************************************************/
  79. {
  80. /*--------------------------- local data ------------------------------*/
  81.  short y,x,fpath_len,fname_len,max_name;
  82.  char buffer[60];
  83.  char display_path[MAX_FILE_NAME+1];
  84.  char *fpath = display_path;
  85.  register int i;
  86. /*--------------------------- processing ------------------------------*/
  87. #ifdef TRACE
  88.  trace_function("show.c:    show_heading");
  89. #endif
  90. /*---------------------------------------------------------------------*/
  91. /* Reset idline to blank.                                              */
  92. /*---------------------------------------------------------------------*/
  93.  wmove(CURRENT_WINDOW_IDLINE,0,0);
  94.  my_wclrtoeol(CURRENT_WINDOW_IDLINE);
  95. /*---------------------------------------------------------------------*/
  96. /* Calculate line,col values.                                          */
  97. /*---------------------------------------------------------------------*/
  98.  getyx(CURRENT_WINDOW,y,x);
  99.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  100.    {
  101.     y = (short)CURRENT_VIEW->current_line;
  102.     x++;
  103.    }
  104.  else
  105.    {
  106.     y = (short)CURRENT_VIEW->focus_line;
  107.     x += CURRENT_VIEW->verify_col;
  108.    }
  109. /*---------------------------------------------------------------------*/
  110. /* Set up buffer for line,col,size and alt values for vertical screens.*/
  111. /*---------------------------------------------------------------------*/
  112.  if (display_screens != 1 && !horizontal)
  113.    {
  114.     sprintf(buffer,"L=%-.1d C=%-.1d S=%-.1d A=%d,%d",
  115.                     y,x,
  116.                     CURRENT_FILE->number_lines,
  117.                     CURRENT_FILE->autosave_alt,
  118.                     CURRENT_FILE->save_alt);
  119.     max_name = (CURRENT_SCREEN.screen_cols-1) - strlen(buffer);
  120.    }
  121.  else
  122.     max_name = (CURRENT_SCREEN.screen_cols-48);
  123. /*---------------------------------------------------------------------*/
  124. /* Determine which portion of filename can be displayed.               */
  125. /*---------------------------------------------------------------------*/
  126.  strcpy(display_path,CURRENT_FILE->fpath);
  127.  fpath = strtrans(display_path,ISLASH,ESLASH);
  128.  fpath_len = strlen(fpath);
  129.  fname_len = strlen(CURRENT_FILE->fname);
  130.  if (fpath_len + fname_len > max_name)
  131.    {
  132.     fpath_len = (fpath_len + fname_len + 3) - max_name;
  133.     wmove(CURRENT_WINDOW_IDLINE,0,0);
  134.     wprintw(CURRENT_WINDOW_IDLINE,"...%s%s",fpath+fpath_len,CURRENT_FILE->fname);
  135.    }
  136.  else
  137.   {
  138.    wmove(CURRENT_WINDOW_IDLINE,0,0);
  139.    wprintw(CURRENT_WINDOW_IDLINE,"%s%s",fpath,CURRENT_FILE->fname);
  140.   }
  141.  if (display_screens != 1 && !horizontal)
  142.    {
  143.     wmove(CURRENT_WINDOW_IDLINE,0,max_name+1);
  144.     wprintw(CURRENT_WINDOW_IDLINE,"%-s",buffer);
  145.    }
  146.  else
  147.    {
  148. /*  wmove(CURRENT_WINDOW_IDLINE,0,34);*/
  149.     wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46);
  150.     wprintw(CURRENT_WINDOW_IDLINE,"Line=%-6.1d Col=%-5.1d",y,x);
  151. /*  wmove(CURRENT_WINDOW_IDLINE,0,54);*/
  152.     wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+20);
  153.     wprintw(CURRENT_WINDOW_IDLINE,"Size=%-6.1d",CURRENT_FILE->number_lines);
  154. /*  wmove(CURRENT_WINDOW_IDLINE,0,66);*/
  155.     wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+32);
  156.     wprintw(CURRENT_WINDOW_IDLINE,"Alt=          ");
  157. /*  wmove(CURRENT_WINDOW_IDLINE,0,70);*/
  158.     wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+36);
  159.     wprintw(CURRENT_WINDOW_IDLINE,"%d,%d",CURRENT_FILE->autosave_alt,
  160.                              CURRENT_FILE->save_alt);
  161.    }
  162.  wnoutrefresh(CURRENT_WINDOW_IDLINE);
  163. #ifdef TRACE
  164.  trace_return();
  165. #endif
  166.  return;
  167. }
  168. /***********************************************************************/
  169. #ifdef PROTO
  170. void show_footing(void)
  171. #else
  172. void show_footing()
  173. #endif
  174. /***********************************************************************/
  175. {
  176. /*------------------------- external data -----------------------------*/
  177.  extern char *rec;
  178.  extern char *cmd_rec;
  179.  extern char *pre_rec;
  180.  extern bool extended_display_mode;
  181.  extern bool colour_support;
  182.  extern char pending_prefix_command[PREFIX_WIDTH+1];
  183.  extern char *the_version;
  184.  extern bool CLOCKx;
  185.  extern bool HEXDISPLAYx;
  186. /*--------------------------- local data ------------------------------*/
  187.  short y,x;
  188.  int key;
  189.  WINDOW *w;
  190.  time_t timer;
  191.  struct tm *tblock;
  192. /*--------------------------- processing ------------------------------*/
  193. #ifdef TRACE
  194.  trace_function("show.c:    show_footing");
  195. #endif
  196.  w = CURRENT_WINDOW;
  197. /*---------------------------------------------------------------------*/
  198. /* Display THE version.                                                */
  199. /*---------------------------------------------------------------------*/
  200.  mvwaddstr(foot,0,0,"THE");
  201.  mvwaddstr(foot,0,4,the_version);
  202. /*---------------------------------------------------------------------*/
  203. /* Display number of files.                                            */
  204. /*---------------------------------------------------------------------*/
  205.  wmove(foot,0,11);
  206.  wprintw(foot,"Files=%d ",number_of_files);
  207. /*---------------------------------------------------------------------*/
  208. /* Display any pending prefix command warning                          */
  209. /*---------------------------------------------------------------------*/
  210.  wmove(foot,0,20);
  211.  if (strcmp(pending_prefix_command,""))
  212.     wprintw(foot,"'%s' pending...",pending_prefix_command);
  213.  else
  214.